<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>个人成绩管理</title>
    <link href="../dist/css/bootstrap.css" rel="stylesheet">
    <link href="../css/docs.css" rel="stylesheet">
    <link href="http://cdn.bootcss.com/highlight.js/7.3/styles/github.min.css" rel="stylesheet">
    <style>
        body
        {
            font-family: "ff-tisa-web-pro-1" , "ff-tisa-web-pro-2" , "Lucida Grande" , "Helvetica Neue" ,Helvetica,Arial, "Hiragino Sans GB" , "Hiragino Sans GB W3" , "WenQuanYi Micro Hei" ,sans-serif;
        }
        h1, .h1, h2, .h2, h3, .h3, h4, .h4, .lead
        {
            font-family: "ff-tisa-web-pro-1" , "ff-tisa-web-pro-2" , "Lucida Grande" , "Helvetica Neue" ,Helvetica,Arial, "Hiragino Sans GB" , "Hiragino Sans GB W3" , "Microsoft YaHei UI" , "Microsoft YaHei" , "WenQuanYi Micro Hei" ,sans-serif;
        }
        pre code
        {
            background: transparent;
        }
        @media (min-width: 900px)
        {
            .bs-docs-home .bs-social, .bs-docs-home .bs-masthead-links
            {
                margin-left: 0;
            }
        }
        .bs-docs-section p
        {
            line-height: 2;
        }
        .bs-docs-section p.lead
        {
            line-height: 1.4;
        }
        .td1
        {
            width: 100px;
            text-align: left;
            height: 32px;
            vertical-align: middle;
            padding-left: 2px 2px 2px 2px;
            line-height: 26px;
        }
        .td2
        {
            width: 300px;
            text-align: left;
            height: 32px;
            line-height: 26px;
            padding: 2px;
            font-size: 14px;
        }
    </style>
    <!--[if lt IE 9]><script src="../docs-assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
  <script src="http://cdn.bootcss.com/html5shiv/3.7.0/html5shiv.min.js"></script>
  <script src="http://cdn.bootcss.com/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
    <link href="../js/themes/base/jquery.ui.all.css" rel="stylesheet" type="text/css" />
    <script src="../js/jquery-1.8.3.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="../js/external/jquery.bgiframe-2.1.2.js"></script>
    <script src="../js/jquery-ui-1.9.2.custom.min.js" type="text/javascript"></script>
    <script src="admin.js" type="text/javascript"></script>
    <script language="javascript">
        var tip = "请输入姓名、单位或比赛项目";
        $(document).ready(function () {
            initText();
            initSelect();

            $("#btnSearch").click(searchData);

            $("#btnAdd").click(function () {
                $("#txtID").val("");
                $("#txtName").val("");
                $("#txtCompany").val("");
                $("#txtChengJi").val("");
                $("#txtSort").val("");

                $("#txtName").prop("disabled", false);
                $("#txtCompany").prop("disabled", false);
                $("#slcItemID").prop("disabled", false);

                $("#txtName").focus();

                $("#dialog-form").dialog("open");
                $("span.ui-dialog-title").text("新增个人成绩");
            });

            $("#dialog-form").dialog({
                autoOpen: false,
                height: 310,
                width: 460,
                modal: true,
                buttons: {
                    "确定": function () {
                        var Name = $("#txtName").val();
                        var Company = $("#txtCompany").val();
                        var Sort = $("#txtSort").val();
                        if (Name == "") {
                            alert("请输入姓名！");
                            $("#txtName").focus();
                            return;
                        }
                        if (Company == "") {
                            alert("请输入单位！");
                            $("#txtCompany").focus();
                            return;
                        }
                        if (Sort == "") {
                            alert("请输入排名！");
                            $("#txtSort").focus();
                            return;
                        }
                        var type = "insert";
                        var ID = $("#txtID").val();
                        if (ID != "") {
                            type = "update";
                        }

                        $.ajax({ url: "ashx/geren.ashx",
                            cache: false,
                            dataType: "json",
                            type: "post",
                            data: { "Name": Name, "Company": Company, "Sort": Sort, "ChengJi": $("#txtChengJi").val(), "ItemID": $("#slcItemID").val(), "ID": ID, "type": type },
                            success: function (data) {
                                $("#txtID").val("");
                                $("#txtName").val("");
                                $("#txtCompany").val("");
                                $("#txtSort").val("");
                                $("#txtChengJi").val("");
                                searchData();
                            }
                        });

                        $("#dialog-form").dialog("close");
                    },
                    "取消": function () {
                        $("#dialog-form").dialog("close");
                    }
                }
            });
        });


        function searchData() {
            var txtval = $("#txtVal").val();
            if (txtval == tip) {
                txtval = "";
            }

            $.ajax({ url: "ashx/geren.ashx",
                cache: false,
                dataType: "json",
                type: "post",
                data: { "text": txtval, "type": "select" },
                success: function (data) {
                    $("#tblResult > tbody").empty();

                    if (data.length == 0) {
                        alert("没有找到符合条件的数据！");
                        return;
                    }

                    var result = new Array();
                    for (i = 0; i < data.length; i++) {
                        result.push("<tr id='tr" + data[i].id + "'><td>" + (i + 1).toString() + "</td>");
                        result.push("<td>" + data[i].name + "</td>");
                        result.push("<td>" + data[i].company + "</td>");
                        result.push("<td>" + data[i].itemname + "</td>");
                        result.push("<td>" + data[i].chengji + "</td>");
                        result.push("<td>" + data[i].sort + "</td>");
                        result.push("<td>" + data[i].score + "</td>");
                        result.push("<td><button type='button' class='btn btn-primary' onclick='updateData(" + data[i].id
                            + ")'>修改</button>&nbsp;&nbsp;<button type='button' class='btn btn-danger' onclick='deleteData(" + data[i].id
                            + ")'>删除</button></td></tr>");
                    }

                    $("#tblResult > tbody").html(result.join(''));
                }
            });
        }
        function updateData(id) {
            $("#txtID").val("");
            $("#txtName").val("");
            $("#txtCompany").val("");
            $("#txtSort").val("");
            $("#txtChengJi").val("");

            $("#txtName").prop("disabled", true);
            $("#txtCompany").prop("disabled", true);
            $("#slcItemID").prop("disabled", true);

            $("span.ui-dialog-title").text("修改个人成绩");

            $.ajax({ url: "ashx/geren.ashx",
                cache: false,
                type: "post",
                data: { "id": id, "type": "selectid" },
                success: function (data) {
                    if (data.length == 0) {
                        return;
                    }
                    $("#txtID").val(id);
                    $("#txtName").val(data[0].name);
                    $("#txtCompany").val(data[0].company);
                    $("#txtSort").val(data[0].sort);
                    $("#slcItemID").val(data[0].itemid);
                    $("#txtChengJi").val(data[0].chengji);
                    $("#txtName").focus();
                    $("#dialog-form").dialog("open");
                }
            });
        }

        function deleteData(id) {
            $.ajax({ url: "ashx/geren.ashx",
                cache: false,
                type: "post",
                data: { "id": id, "type": "delete" },
                success: function (data) {
                    searchData();
                }
            });
        }

        function initText() {//搜索框初始化
            $("#txtVal").val(tip);
            $("#txtVal").css("color", "#ccc");
            $("#txtVal").blur(function () {
                if ($("#txtVal").val() == "") {
                    $("#txtVal").val(tip);
                    $("#txtVal").css("color", "#ccc");
                }
            });

            $("#txtVal").focus(function () {
                if ($("#txtVal").val() == tip) {
                    $("#txtVal").val("");
                    $("#txtVal").css("color", "#000");
                }
            });
        }

        function initSelect() {
            $.ajax({ url: "ashx/gerenItem.ashx",
                type: "post",
                success: function (data) {
                    var result = new Array();
                    for (i = 0; i < data.length; i++) {
                        result.push("<option value=" + data[i].id + ">" + data[i].BiSaiItem + "</option>");
                    }
                    $("#slcItemID").append(result.join(''));
                }
            });
        }
    </script>
</head>
<body>
    <a class="sr-only" href="#content">Skip to main content</a>
    <!-- Docs master nav -->
    <header class="navbar navbar-inverse navbar-fixed-top bs-docs-nav" role="banner">
  <div class="container">
    <div class="navbar-header">
      <button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".bs-navbar-collapse">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a href="../" class="navbar-brand">第六届运动会</a>
    </div>
    <nav class="collapse navbar-collapse bs-navbar-collapse" role="navigation">
      <ul class="nav navbar-nav">
        <li>
          <a href="../index.html">返回首页</a>
        </li>
        

      </ul>
      <ul class="nav navbar-nav navbar-right">
        <li>
          <a href="../about.html">关于</a>
        </li>
      </ul>
    </nav>
  </div>
</header>
    <!-- Callout for the old docs link -->
    <div class="container bs-docs-container">
        <div class="row">
            <div class="col-md-3">
                <div class="bs-sidebar">
                    <ul class="nav bs-sidenav">
                        <li><a href="">信息发布</a>
                            <ul class="">
                                <li><a href="baoming.html">报名展示管理</a></li>
                                <li><a href="tongzhi.html">最新通知管理</a></li>
                            </ul>
                        </li>
                        <li><a href="">赛事报道</a>
                            <ul class="">
                                <li><a href="saishi.html">赛事报道管理</a></li>
                                <li><a href="geren.html">个人成绩管理</a></li>
                                <li><a href="jiti.html">集体成绩管理</a></li>
                            </ul>
                        </li>
                        <li><a href="">风采展示</a>
                            <ul class="">
                                <li><a href="fengcai.html">风采照片管理</a></li>
                                <li><a href="vedio.html">动感视频管理</a></li>
                                <li><a href="jinyi.html">意见建议管理</a></li>
                            </ul>
                        </li>
                        <li><a href="#images">使用帮助</a> </li>
                    </ul>
                </div>
            </div>
            <div class="col-md-9" role="main">
                <!-- Global Bootstrap settings
  ================================================== -->
                <div class="bs-docs-section">
                    <!--==================================-->
                    <h1 id="overview">
                        个人成绩管理</h1>
                    <!---报名查询组件，便于管理员快速查询并修改-->
                    <div class="row">
                        <div class="col-xs-3">
                            <input type="text" class="form-control" id="txtVal" />
                        </div>
                        <button type="button" class="btn btn-success" id="btnSearch">
                            查询</button>&nbsp;&nbsp;
                        <button type="button" class="btn btn-success" id="btnAdd">
                            新增</button>
                    </div>
                    <!--/报名查询组件-->
                    <br />
                    <div class="panel panel-default">
                        <!--<div class="panel-heading">报名信息查询和修改</div>-->
                        <!-- Table -->
                        <table class="table table-bordered" id="tblResult">
                            <thead>
                                <tr>
                                    <th>
                                        序号
                                    </th>
                                    <th>
                                        姓名
                                    </th>
                                    <th>
                                        单位
                                    </th>
                                    <th>
                                        比赛项目
                                    </th>
                                    <th>
                                        成绩
                                    </th>
                                    <th>
                                        排名
                                    </th>
                                    <th>
                                        得分
                                    </th>
                                    <th>
                                        管理
                                    </th>
                                </tr>
                            </thead>
                            <tbody>
                            </tbody>
                        </table>
                        <!--/table-->
                    </div>
                    <!--/panel-->
                </div>
                <!--/bs-docs-section-->
            </div>
        </div>
    </div>
    <!--/container-->
    <!-- Footer
================================================== -->
    <!--<footer class="bs-footer" role="contentinfo">
      <div class="container">
        <p>© 2012 <a href="http://www.cnmtp.com">www.cnmtp.com</a> - 厦门迈科诺信息技术有限公司</p>
      </div>
</footer>-->
    <div id="dialog-form" title="新增个人成绩" style="display: none;">
        <table>
            <tr>
                <td style="width: 20px;">
                </td>
                <td class="td1">
                    <label for="name" style="font-size: 14px;">
                        姓名：</label><input type="hidden" id="txtID" />
                </td>
                <td class="td2">
                    <input type="text" name="name" id="txtName" value="" class="text ui-widget-content ui-corner-all"
                        maxlength="10" style="font-size: 14px;" />
                </td>
            </tr>
            <tr>
                <td style="width: 20px;">
                </td>
                <td class="td1">
                    <label for="Company" style="font-size: 14px;">
                        单位：</label>
                </td>
                <td class="td2">
                    <input type="text" name="Company" id="txtCompany" value="" class="text ui-widget-content ui-corner-all"
                        maxlength="20" style="font-size: 14px;" />
                </td>
            </tr>
            <tr>
                <td style="width: 20px;">
                </td>
                <td class="td1">
                    <label for="ItemID" style="font-size: 14px;">
                        比赛项目：</label>
                </td>
                <td class="td2">
                    <select id="slcItemID">
                    </select>
                </td>
            </tr>
            <tr>
                <td style="width: 20px;">
                </td>
                <td class="td1">
                    <label for="ChengJi" style="font-size: 14px;">
                        成绩：</label>
                </td>
                <td class="td2">
                    <input type="text" name="ChengJi" id="txtChengJi" value="" class="text ui-widget-content ui-corner-all"
                        maxlength="20" style="font-size: 14px;" />
                </td>
            </tr>
            <tr>
                <td style="width: 20px;">
                </td>
                <td class="td1">
                    <label for="Sort" style="font-size: 14px;">
                        排名：</label>
                </td>
                <td class="td2">
                    <input type="text" name="Sort" id="txtSort" value="" class="text ui-widget-content ui-corner-all"
                        maxlength="2" style="font-size: 14px;" onkeyup="this.value=this.value.replace(/\D/g,'')"
                        onafterpaste="this.value=this.value.replace(/\D/g,'')" />
                </td>
            </tr>
        </table>
    </div>
</body>
</html>
